package com.mou.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.github.pagehelper.Page;
import com.mou.dto.CategoryPageQueryDTO;
import com.mou.entity.Category;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

public interface CategoryMapper extends BaseMapper<Category> {

    Page<Category> pageQuery(CategoryPageQueryDTO categoryPageQueryDTO);

    @Select("select count(1) from category where parent_id = #{id}")
    Integer getCountByParentId(Integer id);
    @Update("update category set deleted = 1 where id = #{id}")
    void deleted(Integer id);
    @Select("select * from category where name = #{name} or id = #{id}")
    Category getCategory(Category category);

    @Select("select id from category where name = #{category}")
    Integer getIdByName(String category);
}
